package com.operation;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBConnection {
	
	public static Connection getMySQLConnection() {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		ResultSet res = null;
		try {
			
			// 加载Connector/J驱动
			Class.forName("com.mysql.jdbc.Driver");
			// Class.forName("org.postgresql.Driver").newInstance();
			// 建立到MySQL的连接
			conn = DriverManager.getConnection(
					"jdbc:mysql://localhost:3308/test", "root", "666666");
				
		} catch (Exception ex) {
			System.out.println("Error : " + ex.toString());
		}
		return conn;
	}
	
	public void close(Connection conn, ResultSet rs) {
		try {
			conn.close();
			rs.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
